package com.tz.actions;

import com.opensymphony.xwork2.ActionSupport;
import com.tz.entity.FaqItem;
import com.tz.service.FaqService;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
 * Created by robin on 2016/8/5 0005.
 */
@Namespace("/")
@ParentPackage("json-default")
public class FaqAction extends ActionSupport{

    @Autowired
    private FaqService faqService;

    private List<FaqItem> items;

    @Action(value = "faqs",results = {
            @Result(type = "json",params = {"root","items"})
    })
    public String faqs(){
        items = faqService.getAll();
        return SUCCESS;
    }

    public List<FaqItem> getItems() {
        return items;
    }

    public void setItems(List<FaqItem> items) {
        this.items = items;
    }
}
